package com.sxt.bus.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sxt.bus.domain.Customer;
import com.sxt.bus.mapper.CustomerMapper;
import com.sxt.bus.service.CustomerService;
import com.sxt.bus.vo.CustomerVo;
import com.sxt.bus.utils.DataGridView;
@Service
public class CustomerServiceImpl implements CustomerService{

	@Autowired
	private CustomerMapper customerMapper;
	
	
	@Override
	public DataGridView queryAllCustomer(CustomerVo customerVo) {
		Page<Object> page = PageHelper.startPage(customerVo.getPage(),customerVo.getLimit());
		List<Customer> data = customerMapper.queryAllCustomer(customerVo);
		return new DataGridView(page.getTotal(),data);
	}

	@Override
	public Integer updateCustomer(CustomerVo customerVo) {
		// TODO Auto-generated method stub
		return customerMapper.updateByPrimaryKeySelective(customerVo);
	}

	@Override
	public Integer addCustomer(CustomerVo customerVo) {
		// TODO Auto-generated method stub
		return customerMapper.insertSelective(customerVo);
	}

	@Override
	public Integer deleteCustomer(Integer id) {
		// TODO Auto-generated method stub
		return customerMapper.deleteByPrimaryKey(id);
	}

}
